import {api} from "@/utils/request";


// 更新头像
export const updateAvatarApi = (data: any) => {
    
    return api({
        url: "/user/sys/updateAvatar",
        method: "post",
        data,
    })
}

// 系统用户退出
export const logoutApi = () => {
    return api({
        url: "/sys/user/logout",
        method: "get"
    })
}
// 修改当前用户信息
export const updateUserInfoApi = (data: any) => {
    return api({
        url: "/sys/user/updateUserInfo",
        method: "post",
        data,
    })

}

// 获取全部用户信息

export const getUserListApi = () => {
    return api({
        url: "/sys/user/getAllUser",
        method: "get"
    })
}

// 分页查询所有、带上条件

export const GetSysUserListByPage = (pageNum:number , pageSize:number , queryDto:any) => {
    return api({
        url: "/sys/user/findByPage/" + pageNum + "/" + pageSize,
        method: 'get',
        params: queryDto
    })

}

// 新增用户
export const addUserApi = (data:any) => {
    return api({
        url: "/sys/user/addUser",
        method: "post",
        data: data
    })
}
// 修改用户
export const updateUserApi = (data:any) => {
    return api({
        url: "/sys/user/updateSysUser",
        method: "put",
        data: data
    })
}


// //    根据id删除用户
export const deletedById = (id:any) => {
    return api({
        url: "/sys/user/deletedById/"+id,
        method: "delete",
    })
}


// 给用户分配角色

export const addRoleToUser = (data:any) => {
    return api({
        url: "/sys/role/userRole",
        method: "post",
        data: data
    })
}



// //用户拥有角色数据回显

export const toUserRoles = (userId:number) => {
    return api({
        url: "/sys/role/findAllRoles/"+userId,
        method: "get"
    })
}


